package ${managerPackage};

import ${entityPackage}.${domainObjectName};
import ${mapperPackage}.${domainObjectName}Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;

/**
 * ${tableComment!} 通用业务处理层
 * @author ${author!}
 * @date ${date?string("yyyy-MM-dd")}
 */
@Component
public class ${domainObjectName}Manager {

    @Autowired
    private ${domainObjectName}Mapper ${domainObjectName?uncap_first}Mapper;

    /**
     * 新增
     */
    public int insert(${domainObjectName} ${domainObjectName?uncap_first}) {
        return ${domainObjectName?uncap_first}Mapper.insertSelective(${domainObjectName?uncap_first});
    }

    /**
     * 更新
     */
    public int update(${domainObjectName} ${domainObjectName?uncap_first}) {
        return ${domainObjectName?uncap_first}Mapper.updateByPrimaryKeySelective(${domainObjectName?uncap_first});
    }

    /**
     * 删除
     */
    public int deleteById(${primaryKeyJavaType} id) {
        return ${domainObjectName?uncap_first}Mapper.deleteByPrimaryKey(id);
    }

    /**
     * 根据ID查询
     */
    public ${domainObjectName} selectById(${primaryKeyJavaType} id) {
        return ${domainObjectName?uncap_first}Mapper.selectByPrimaryKey(id);
    }

    /**
     * 查询所有
     */
    public List<${domainObjectName}> selectAll() {
        return ${domainObjectName?uncap_first}Mapper.selectAll();
    }
}

<#-- 查找主键类型 -->
<#assign primaryKeyJavaType = "Long">
<#list columns as column>
    <#if column.primaryKey>
        <#assign primaryKeyJavaType = column.javaType>
    </#if>
</#list>
